Use enum values instead of plain numbers for the file lists's sort
authorFederico Mena Quintero <federico@ximian.com>
Wed, 1 Oct 2003 19:42:50 +0000 (19:42 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Wed, 1 Oct 2003 19:42:50 +0000 (19:42 +0000)
commitda293525875f046ba2a42ade4ec7985ff751fb82
tree9d944d070a961989377452b06db119cdcdee3bb6
parent6e87629f1aacda1e6c23ca46cf9d27891ee0e520
Use enum values instead of plain numbers for the file lists's sort

2003-10-01  Federico Mena Quintero  <federico@ximian.com>

* gtkfilechooserimpldefault.c (tree_selection_changed): Use enum
values instead of plain numbers for the file lists's sort columns.
(create_file_list): Likewise.
(tree_selection_changed): Make the file list start up sorted by
name, and don't specify a default sorting function, so that there
is no unsorted order.  This is for consistency with Nautilus.
(list_sort_column_changed_cb): Callback; we cache whether the sort
order for the file list's name column is ascending or not.
(compare_with_folders_first): New helper function to sort
directories before files.
(name_sort_func): Use compare_with_folders_first().
(size_sort_func): Likewise.
(mtime_sort_func): Likewise.

Of course this callback mess would be easy in a real language:

  (set-sort-func sortable NAME_COLUMN
    (make-comparer impl (lambda (a b) (strcmp (get-name a) (get-name b)))))
  (set-sort-func sortable SIZE_COLUMN
    (make-comparer impl (lambda (a b) (compare (get-size a) (get-size b)))))
  ... etc ...

  (define (make-comparer impl f)
    (lambda (a b)
      (if (eq (is-dir? a) (is-dir? b))
          (f a b)
  (if (sort-ascending? impl)
      (if (is-dir? a) -1 1)
      (if (is-dir? a) 1 -1)))))
gtk/gtkfilechooserdefault.c